<template>
  <div>
    <div style="border: 1px solid red">金额规则:
      <br/>
      1.乘客//
      起步价:{{this.moneyRules.operatePassengerCharges.startingPrice+"元"}}--
      起步公里:{{this.moneyRules.operatePassengerCharges.startingKilometer+"公里"}}--
      里程费:{{this.moneyRules.operatePassengerCharges.mileageFee+"元"}}--
      免费等待时间:{{this.moneyRules.operatePassengerCharges.startingKilometer+"分钟"}}--
      超过等待时间的费用:{{this.moneyRules.operatePassengerCharges.departureWaitingPrice+"元"}}--
      免费取消时间:{{this.moneyRules.operatePassengerCharges.timeoutCancellationTime+"分钟"}}
      <br/>
      2.司机//
      平台服务类型:{{this.moneyRules.operateDriverCharges.serviceType==1?"比例"+this.moneyRules.operateDriverCharges.serviceProportion:"固定金额"+this.moneyRules.operateDriverCharges.servicePrice+"元"}}--
      平台管理类型:{{this.moneyRules.operateDriverCharges.manageType==1?"比例"+this.moneyRules.operateDriverCharges.manageProportion:"固定金额"+this.moneyRules.operateDriverCharges.managePrice+"元"}}--
      保险费:{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}--
      免费取消时间:{{this.moneyRules.operatePassengerCharges.orderCancellationTime+"分钟"}}
    </div>
  <div v-show="this.order.orderInformation.orderStatus==6 ||this.order.orderInformation.orderStatus==7 ">
    订单历程:{{this.order.orderInformation.orderMileage+"公里"}}
    <br/>
    司机等待时间:{{this.c+"分钟"}}
    <br/>
    高速费:{{this.order.orderCost.highwayFee==null?"无":this.order.orderCost.highwayFee+"元"}}
    <br/>
    路桥费: {{this.order.orderCost.bridgeFee==null?"无":this.order.orderCost.bridgeFee+"元"}}
    <br/>
    停车费:{{this.order.orderCost.parkingFee==null?"无":this.order.orderCost.parkingFee+"元"}}
    <br/>
    附加费:{{this.order.orderCost.additionalFee==null?"无":this.order.orderCost.additionalFee+"元"}}
    <br/>
    优惠金额:{{this.order.orderCost.preferentialMoney==null?"无":this.order.orderCost.preferentialMoney+"元"}}
    <br/>
    <div v-if="this.order.orderInformation.orderMileage<=this.moneyRules.operatePassengerCharges.startingKilometer && this.c<=this.moneyRules.operatePassengerCharges.departureWaitingTime">
      订单费用(小于起步公里不超过免费等待时间):{{this.moneyRules.operatePassengerCharges.startingPrice+"元"}}
      +{{this.order.orderCost.highwayFee==null?"无":this.order.orderCost.highwayFee+"元"}}
      +{{this.order.orderCost.bridgeFee==null?"无":this.order.orderCost.bridgeFee+"元"}}
      +{{this.order.orderCost.parkingFee==null?"无":this.order.orderCost.parkingFee+"元"}}
      +{{this.order.orderCost.additionalFee==null?"无":this.order.orderCost.additionalFee+"元"}}
      -{{this.order.orderCost.preferentialMoney==null?"无":this.order.orderCost.preferentialMoney+"元"}}
      ={{this.jg+"元"}}
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==1 && this.moneyRules.operateDriverCharges.manageType==1">
        司机收益:{{this.jg+"元"}}
        -({{this.moneyRules.operateDriverCharges.serviceProportion+"%"}}*{{this.jg+"元"}})
        -({{this.moneyRules.operateDriverCharges.manageProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==1 && this.moneyRules.operateDriverCharges.manageType==2">
        司机收益:{{this.jg+"元"}}
        -({{this.moneyRules.operateDriverCharges.serviceProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.managePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==2 && this.moneyRules.operateDriverCharges.manageType==1">
        司机收益:{{this.jg+"元"}}
        -{{this.moneyRules.operateDriverCharges.servicePrice+"元"}}
        -({{this.moneyRules.operateDriverCharges.manageProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==2 && this.moneyRules.operateDriverCharges.manageType==2">
        司机收益:{{this.jg+"元"}}
        -{{this.moneyRules.operateDriverCharges.servicePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.managePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
    </div>
    <div v-if="this.order.orderInformation.orderMileage<=this.moneyRules.operatePassengerCharges.startingKilometer && this.c>this.moneyRules.operatePassengerCharges.departureWaitingTime">
      订单费用(小于起步公里超过免费等待时间):{{this.moneyRules.operatePassengerCharges.startingPrice+"元"}}
      +{{this.c-this.moneyRules.operatePassengerCharges.departureWaitingTime}}*{{this.moneyRules.operatePassengerCharges.departureWaitingPrice+"元"}}
      +{{this.order.orderCost.highwayFee==null?"无":this.order.orderCost.highwayFee+"元"}}
      +{{this.order.orderCost.bridgeFee==null?"无":this.order.orderCost.bridgeFee+"元"}}
      +{{this.order.orderCost.parkingFee==null?"无":this.order.orderCost.parkingFee+"元"}}
      +{{this.order.orderCost.additionalFee==null?"无":this.order.orderCost.additionalFee+"元"}}
      -{{this.order.orderCost.preferentialMoney==null?"无":this.order.orderCost.preferentialMoney+"元"}}
      ={{this.jg+"元"}}
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==1 && this.moneyRules.operateDriverCharges.manageType==1">
        司机收益:{{this.jg+"元"}}
        -({{this.moneyRules.operateDriverCharges.serviceProportion+"%"}}*{{this.jg+"元"}})
        -({{this.moneyRules.operateDriverCharges.manageProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==1 && this.moneyRules.operateDriverCharges.manageType==2">
        司机收益:{{this.jg+"元"}}
        -({{this.moneyRules.operateDriverCharges.serviceProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.managePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==2 && this.moneyRules.operateDriverCharges.manageType==1">
        司机收益:{{this.jg+"元"}}
        -{{this.moneyRules.operateDriverCharges.servicePrice+"元"}}
        -({{this.moneyRules.operateDriverCharges.manageProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==2 && this.moneyRules.operateDriverCharges.manageType==2">
        司机收益:{{this.jg+"元"}}
        -{{this.moneyRules.operateDriverCharges.servicePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.managePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
    </div>
    <div v-if="this.order.orderInformation.orderMileage>this.moneyRules.operatePassengerCharges.startingKilometer && this.c<=this.moneyRules.operatePassengerCharges.departureWaitingTime">
      订单费用(大于起步公里不超过免费等待时间):{{this.moneyRules.operatePassengerCharges.startingPrice+"元"}}
      +{{this.order.orderInformation.orderMileage-this.moneyRules.operatePassengerCharges.startingKilometer}}*{{this.moneyRules.operatePassengerCharges.mileageFee+"元"}}
      +{{this.order.orderCost.highwayFee==null?"无":this.order.orderCost.highwayFee+"元"}}
      +{{this.order.orderCost.bridgeFee==null?"无":this.order.orderCost.bridgeFee+"元"}}
      +{{this.order.orderCost.parkingFee==null?"无":this.order.orderCost.parkingFee+"元"}}
      +{{this.order.orderCost.additionalFee==null?"无":this.order.orderCost.additionalFee+"元"}}
      -{{this.order.orderCost.preferentialMoney==null?"无":this.order.orderCost.preferentialMoney+"元"}}
      ={{this.jg+"元"}}
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==1 && this.moneyRules.operateDriverCharges.manageType==1">
        司机收益:{{this.jg+"元"}}
        -({{this.moneyRules.operateDriverCharges.serviceProportion+"%"}}*{{this.jg+"元"}})
        -({{this.moneyRules.operateDriverCharges.manageProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==1 && this.moneyRules.operateDriverCharges.manageType==2">
        司机收益:{{this.jg+"元"}}
        -({{this.moneyRules.operateDriverCharges.serviceProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.managePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==2 && this.moneyRules.operateDriverCharges.manageType==1">
        司机收益:{{this.jg+"元"}}
        -{{this.moneyRules.operateDriverCharges.servicePrice+"元"}}
        -({{this.moneyRules.operateDriverCharges.manageProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==2 && this.moneyRules.operateDriverCharges.manageType==2">
        司机收益:{{this.jg+"元"}}
        -{{this.moneyRules.operateDriverCharges.servicePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.managePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
    </div>
    <div v-if="this.order.orderInformation.orderMileage>this.moneyRules.operatePassengerCharges.startingKilometer && this.c>this.moneyRules.operatePassengerCharges.departureWaitingTime">
      订单费用(大于起步公里超过免费等待时间):{{this.moneyRules.operatePassengerCharges.startingPrice+"元"}}
      +{{this.order.orderInformation.orderMileage-this.moneyRules.operatePassengerCharges.startingKilometer}}*{{this.moneyRules.operatePassengerCharges.mileageFee+"元"}}
      +{{this.c-this.moneyRules.operatePassengerCharges.departureWaitingTime}}*{{this.moneyRules.operatePassengerCharges.departureWaitingPrice+"元"}}
      +{{this.order.orderCost.highwayFee==null?"无":this.order.orderCost.highwayFee+"元"}}
      +{{this.order.orderCost.bridgeFee==null?"无":this.order.orderCost.bridgeFee+"元"}}
      +{{this.order.orderCost.parkingFee==null?"无":this.order.orderCost.parkingFee+"元"}}
      +{{this.order.orderCost.additionalFee==null?"无":this.order.orderCost.additionalFee+"元"}}
      -{{this.order.orderCost.preferentialMoney==null?"无":this.order.orderCost.preferentialMoney+"元"}}
      ={{this.jg+"元"}}
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==1 && this.moneyRules.operateDriverCharges.manageType==1">
        司机收益:{{this.jg+"元"}}
        -({{this.moneyRules.operateDriverCharges.serviceProportion+"%"}}*{{this.jg+"元"}})
        -({{this.moneyRules.operateDriverCharges.manageProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==1 && this.moneyRules.operateDriverCharges.manageType==2">
        司机收益:{{this.jg+"元"}}
        -({{this.moneyRules.operateDriverCharges.serviceProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.managePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==2 && this.moneyRules.operateDriverCharges.manageType==1">
        司机收益:{{this.jg+"元"}}
        -{{this.moneyRules.operateDriverCharges.servicePrice+"元"}}
        -({{this.moneyRules.operateDriverCharges.manageProportion+"%"}}*{{this.jg+"元"}})
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
      <div v-if="this.moneyRules.operateDriverCharges.serviceType==2 && this.moneyRules.operateDriverCharges.manageType==2">
        司机收益:{{this.jg+"元"}}
        -{{this.moneyRules.operateDriverCharges.servicePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.managePrice+"元"}}
        -{{this.moneyRules.operateDriverCharges.insurancePrice+"元"}}
        ={{this.dirvermoney+"元"}}
      </div>
    </div>
    </div>

    <div v-show="this.order.orderInformation.orderStatus== 3">
    乘客已取消
      <br/>
      取消原因:{{this.order.orderInformation.closeCause }}
      <br/>
      取消时间:{{this.cc+"分钟"}}
      <div v-if="this.cc>this.moneyRules.operatePassengerCharges.timeoutCancellationTime">
        超出免费取消时间 乘客须付款{{this.moneyRules.operatePassengerCharges.timeoutCancellationPrice+"元"}}
      </div>
      <div v-if="this.cc<=this.moneyRules.operatePassengerCharges.timeoutCancellationTime">
        在免费取消时间内 无需付款
      </div>

    </div>

    <div v-show="this.order.orderInformation.orderStatus== 4">
    司机已取消
      <br/>
      取消原因:{{this.order.orderInformation.closeCause }}
      <br/>
      取消时间:{{this.cc+"分钟"}}
      <div v-if="this.cc>this.moneyRules.operatePassengerCharges.orderCancellationTime">
        超出免费取消时间 你须付款{{this.moneyRules.operatePassengerCharges.orderCancellationPrice+"元"}}
      </div>
      <div v-if="this.cc<=this.moneyRules.operatePassengerCharges.orderCancellationTime">
        在免费取消时间内 无需付款
      </div>
    </div>



    <div v-show="this.order.orderInformation.orderStatus==1 ||this.order.orderInformation.orderStatus==2">
      订单未完成
    </div>
  </div>
</template>
<script>

import {getmonth,getorderMoney,getdrivermoney} from "@/components/api/historyorder/historyorder"
export default {

  data() {
    return {
      c:null,
      cc:null,
      order:{},
      moneyRules:{},
      jg:null,
      dirvermoney:null,
    };
  },


  created() {
   this.order=this.$route.query.order;
   this.getmonth();
   if(this.order.orderInformation.orderStatus==6 || this.order.orderInformation.orderStatus==7){
     this.calculateMinutesDifference();
     this.getorderMoney();
   }
  if(this.order.orderInformation.orderStatus==3 || this.order.orderInformation.orderStatus==4){
    this.cancelc();
  }


  },

  methods: {
    getdrivermoney(jg){
      getdrivermoney(jg).then(res=>{
      this.dirvermoney=res.data;
      })
    },
    getorderMoney(){
      getorderMoney(this.order).then(res=>{
        this.jg=res.data;
        this.getdrivermoney(this.jg);
      })

    },
    //取消时间的差
    cancelc(){
      // 将日期转换为时间戳（毫秒）
      const time1 = new Date(this.order.orderTime.cancelTime).getTime();
      const time2 = new Date(this.order.orderTime.takeorderTime).getTime();
      // 计算时间差（毫秒）
      const differenceInMillis = Math.abs(time1 - time2);
      // 将毫秒差转换为分钟差
      const differenceInMinutes = Math.floor(differenceInMillis / (1000));
      this.cc=Math.ceil(differenceInMinutes/60);
    },
    //时间差
    calculateMinutesDifference() {
      // 将日期转换为时间戳（毫秒）
      const time1 = new Date(this.order.orderTime.receiveTime).getTime();
      const time2 = new Date(this.order.orderTime.arriveTime).getTime();
      // 计算时间差（毫秒）
      const differenceInMillis = Math.abs(time1 - time2);
      // 将毫秒差转换为分钟差
      const differenceInMinutes = Math.floor(differenceInMillis / (1000));
      this.c=Math.ceil(differenceInMinutes/60);
      },
    //计算规则
    getmonth(){
      getmonth().then(res=>{
        this.moneyRules=res.data;
      })
    }
  },


};
</script>
<style>

</style>
